﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using System.Windows.Threading;
using Slex.Timeline;

namespace Test.Scenes {
    public partial class Cartoon4 : Page {
        public Cartoon4() {
            InitializeComponent();
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(400);
            timer.Tick += timer_Tick;
            var r = from item in LayoutRoot.Children select item as FrameworkElement;
            //ea = Cartoon.Actions(Cartoon.Geta(250, ct: CartoonType.Transform), r.ToArray());
            ea = Cartoon.Actions(Cartoon.Geta(410, ct: CartoonType.Projection), r.ToArray());
            ran = new Random(); ran2 = new Random();
            Loaded += Cartoon4_Loaded;
            Unloaded += Cartoon4_Unloaded;
        }

        void Cartoon4_Unloaded(object sender, RoutedEventArgs e) {
            timer.Stop();
        }

        void Cartoon4_Loaded(object sender, RoutedEventArgs e) {
            timer.Start();
        }
        EntityxsAction ea; Random ran, ran2;
        void timer_Tick(object sender, EventArgs e) {
            foreach (FrameworkElement item in LayoutRoot.Children) {
                var group = ea[item.Name];
                //ea.Get(group, "ctx").Valued = ran.Next(360);
                //ea.Get(group, "cty").Valued = ran.Next(360);
                //ea.Get(group, "ctr").Valued = ran.Next(360);
                ea.Get(group, "pplx").Valued = ran.Next(360);
                ea.Get(group, "pply").Valued = ran.Next(360);
                ea.Get(group, "pplz").Valued = ran.Next(360);
                ea.Get(group, "pprx").Valued = ran.Next(360);
                ea.Get(group, "ppry").Valued = ran.Next(360);
                ea.Get(group, "pprz").Valued = ran.Next(360);

            }
            ea.Storyboard.Begin();
        }
        DispatcherTimer timer;
        // 当用户导航到此页面时执行。
    }
}
